package com.genersoft.iot.vmp.vmanager.alarm;

import com.genersoft.iot.vmp.gb28181.bean.DeviceAlarm;
import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
import com.github.pagehelper.PageInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@CrossOrigin
@RestController
@RequestMapping("/api")
public class AlarmController {

    private final static Logger logger = LoggerFactory.getLogger(AlarmController.class);

    @Autowired
    private IVideoManagerStorager storager;

    @GetMapping("/alarms")
    public PageInfo<DeviceAlarm> alarms(int page, int count){
        if (logger.isDebugEnabled()) {
            logger.debug("查询所有报警历史API调用");
        }

        return storager.queryAlarmList(page, count);
    }

    @GetMapping("/alarms/{deviceId}")
    public PageInfo<DeviceAlarm> alarms(int page, int count, @PathVariable String deviceId){
        if (logger.isDebugEnabled()) {
            logger.debug("查询设备报警历史API调用");
        }

        return storager.queryAlarmListByDeviceId(page, count, deviceId);
    }
}
